function Enemy(type) {
	var self = this
	self.body = document.createElement("div")
	self.init = function() {
		switch(type) {
			case GameEngine.cons.PLANE_TYPE_SMALL:
				{
					self.body.className = "enemy-small";
					self.speed = 10;
					self.score =10;
					self.hp = 1
					self.imgs = ["plain1_die1.png", "plain1_die2.png", "plain1_die3.png"];
					break;
				}
			case GameEngine.cons.PLANE_TYPE_MIDDLE:
				{
					self.body.className = "enemy-middle"
					self.speed = 5;
					self.score=30;
					self.hp = 5
					self.imgs = ["plain2_die1.png", "plain2_die2.png", "plain2_die3.png", "plain2_die4.png"];
					break;
				}
			case GameEngine.cons.PLANE_TYPE_LARGE:
				{
					self.body.className = "enemy-large"
					self.speed = 2;
					self.score=50
					self.hp = 10
					self.imgs = ["plain3_die1.png", "plain3_die2.png", "plain3_die3.png", "plain3_die4.png", "plain3_die5.png", "plain3_die6.png"];
					break;
				}
		}
		ge.body.appendChild(self.body)
		self.left(Math.round(Math.random() * (ge.width() - self.width())))
		self.top(-self.height())
		return self
	}
	self.left = function(val) {
		if(val != undefined) {
			self.body.style.left = val + "px";
		} else {
			return self.body.offsetLeft;
		}
	}
	self.top = function(val) {
		if(val != undefined) {
			self.body.style.top = val + "px";
		} else {
			return self.body.offsetTop;
		}
	}
	self.hurt = function() {
		if(--self.hp == 0) {
			self.explode()
		}
	}
	self.explode = function() {
		clearInterval(self.movetimer)
		ge.score(ge.score()+self.score)
		self.exptimer=setInterval(function(){
			if(!GameEngine.pause){
				var imgurl=self.imgs.shift()
				if(imgurl){
					self.body.style.background="url(images/"+imgurl+")"
				}else{
					clearInterval(self.exptimer)
					self.destroy()
				}
			}
		},80)
	}
	self.width = function() {
		return self.body.offsetWidth
	}
	self.height = function() {
		return self.body.offsetHeight
	}
	self.move = function() {
		self.movetimer = setInterval(function() {
			if(!GameEngine.pause){
				self.body.style.top = self.top() + self.speed + "px";
				if(ge.isOverlap(self, myplane)) {
					self.explode()
					//alert("游戏结束!");
					new Promise(myplane.destroy).then(function(){
						ge.gameover()
					})
				}
				if(self.top() > window.innerHeight) {
					clearInterval(self.movetimer)
					self.destroy()
				}
			}
		}, 30);
		return self;
	}
	self.destroy = function() {
		//从敌人列表中删除自己
		ge.enemes.delete(self)
		self.body.remove()
	}
}